<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
        
    </body>
</html>
<script>
    
    var arr = ["apple", "orange", "melon"];

    for (var i = 0; i < arr.length; i++) {
        console.log(arr[i]);
    }

    var obj = {
        name: "小明",
        "0": "apple",
        "1": "orange",
        2: "melon",
        length: 3
    };
    console.log(obj.name);
    console.log(obj["name"]);
    console.log(obj["0"]);

    for (var i = 0; i < obj.length; i++) {
        console.log(obj[i]);
    }

    console.log(arr.forEach);
    console.log(obj.forEach);


    function func() {
        var a = 5;
        function f() {
            a++;
            console.log(a);
        }
        return f;
    }

    // func();
    // func();
    // func();
    // console.log(a);
    var f1 = func();
    f1();
    f1();
    f1();

    f1 = null;

    var f2;
    function func3() {
        var b = 3;
        f2 = function() {
            b++;
            console.log(b);
        }
    }
    func3();
    f2();
    f2();
    f2();


    // (function() {
    //     alert(333);
    // })();

    var f5 = new Function("var a = 5; b = 3; console.log(a + b);");
    console.log(f5);
    f5();


    !function(sum, sub, mul, div) {

        console.log(sum(5, 6));
        console.log(sub(6, 7));

















    }(function(a, b) {
        return a + b;
    }, function(a, b) {
        return a - b;
    }, function(a, b) {
        return a * b;
    }, function(a , b) {
        return a / b;
    });




    setTimeout(function() {

        console.log("hello, world");



    }, 3000);

    function sum(a, b) {
        console.log(a, b);
        return a + b;
    }

    function sub(a, b) {
        return a - b;
    }

    function func6(callback, a, b) {

        for (var i = 0; i < 100; i++) {
            console.log(i);
        }

        console.log(callback(a, b));
    }

    func6(sum, 5, 8);





</script>